package com.spa.application.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.spa.infrastructure.util.CurrencyUtils;

import java.math.BigDecimal;

/**
 * excel导出转换金额分->元转换
 */
public class AmountIntegerToYuanConverter implements Converter<Integer> {

    @Override
    public Class<?> supportJavaTypeKey() {
        return Integer.class;
    }
    @Override
    public WriteCellData<String> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
            GlobalConfiguration globalConfiguration) {
        if(value == null || value.equals("")){
            return new WriteCellData<String>((String) null);
        }
        BigDecimal data = CurrencyUtils.fenToYuan(value);
        return new WriteCellData<String>(data);
    }

}
